#include <iostream>
#include "contacts.pb.h"

int main()
{
    std::string res;
    {
        contacts::PeopleInfo people;
        people.set_name("张三");
        people.set_age(20);
        if (!people.SerializePartialToString(&res))
        {
            std::cout << "序列化失败..." << std::endl;
            return 1;
        }
        std::cout << "序列化后的结果: " << res << std::endl;
    }

    {
        contacts::PeopleInfo people;
        if (!people.ParseFromString(res))
        {
            std::cout << "反序列化失败..." << std::endl;
            return 1;
        }
        std::cout << "姓名: " << people.name() << std::endl;
        std::cout << "年龄: " << people.age() << std::endl; 
    }

    return 0;
}